home *** CD-ROM | disk | FTP | other *** search
/ MacWarehouse Macintosh Games / MacWarehouse Macintosh Games.iso / AMBER demo / ROXY / ROXY.dxr / 00004_utility scripts.ls < prev    next >
Encoding:
Text File  |  1996-10-18  |  14.7 KB  |  425 lines

  1. on camLogInit
  2.   global oPuppeteer, oStoryteller, gOriginPoint, gCPU
  3.   freezeInventory()
  4.   disablePeekAlert()
  5.   if getState(oStoryteller, #playerHasVideotape) = #usedUp then
  6.     puppetSprite(45, 1)
  7.     updateStage()
  8.     set the castNum of sprite 45 to getProp(the lsForegroundData of oPuppeteer, #camRewind)
  9.     set the visible of sprite 45 to 0
  10.     set the loc of sprite 45 to point(323, 213) + gOriginPoint
  11.     set storedPosition to getState(oStoryteller, #videoTapePosition)
  12.     if storedPosition <> #none then
  13.       set the movieTime of sprite 44 to storedPosition
  14.     end if
  15.     if gCPU = #PC then
  16.       suspendSounds(#fadeOut)
  17.     end if
  18.   end if
  19.   updateStage()
  20. end
  21.  
  22. on camLogShutdown
  23.   global oPuppeteer, oStoryteller, gCPU
  24.   unFreezeInventory()
  25.   enablePeekAlert()
  26.   set storedPosition to getState(oStoryteller, #videoTapePosition)
  27.   if storedPosition <> #none then
  28.     setState(oStoryteller, #videoTapePosition, the movieTime of sprite 44)
  29.   end if
  30.   puppetSprite(45, 0)
  31.   updateStage()
  32.   if (getState(oStoryteller, #playerHasVideotape) = #usedUp) and (gCPU = #PC) then
  33.     restoreSounds(#fadeIn)
  34.   end if
  35. end
  36.  
  37. on camControl whichBtn
  38.   global oStoryteller, oPuppeteer
  39.   set storedPosition to getState(oStoryteller, #videoTapePosition)
  40.   set buttonStack to getProp(the lsMultiFrames of oPuppeteer, #camButtons)
  41.   set buttonSprite to 0
  42.   repeat with i = 10 to 48
  43.     if getPos(buttonStack, the castNum of sprite i) then
  44.       set buttonSprite to i
  45.       exit repeat
  46.     end if
  47.   end repeat
  48.   set markerList to [60, 2168, 4448, 7922, 12490, 15000]
  49.   if whichBtn = #prevMarker then
  50.     set the castNum of sprite buttonSprite to getAt(buttonStack, 3)
  51.   end if
  52.   if whichBtn = #play then
  53.     set the castNum of sprite buttonSprite to getAt(buttonStack, 4)
  54.   end if
  55.   if whichBtn = #nextMarker then
  56.     set the castNum of sprite buttonSprite to getAt(buttonStack, 5)
  57.   end if
  58.   if whichBtn = #pause then
  59.     set the castNum of sprite buttonSprite to getAt(buttonStack, 6)
  60.   end if
  61.   updateStage()
  62.   set buttonDownTime to the ticks
  63.   repeat while the ticks < (buttonDownTime + 8)
  64.     nothing()
  65.   end repeat
  66.   set the castNum of sprite buttonSprite to getAt(buttonStack, 2)
  67.   if integerp(storedPosition) then
  68.     set currentPosition to the movieTime of sprite 44
  69.     set currentSegment to 1
  70.     repeat with i = 1 to count(markerList)
  71.       if getAt(markerList, i) <= currentPosition then
  72.         set currentSegment to i
  73.       end if
  74.     end repeat
  75.     set onScreen to the loc of sprite 44
  76.     set offScreen to the loc of sprite 45
  77.     if (whichBtn = #prevMarker) or (whichBtn = #nextMarker) then
  78.       if (whichBtn = #prevMarker) and (currentSegment > 1) then
  79.         set currentSegment to currentSegment - 1
  80.       end if
  81.       if (whichBtn = #nextMarker) and (currentSegment < count(markerList)) then
  82.         set currentSegment to currentSegment + 1
  83.       end if
  84.       set newPosition to getAt(markerList, currentSegment)
  85.       set trueLength to abs(the movieTime of sprite 44 - newPosition) / 20
  86.       set maxLength to 300
  87.       set rewindLength to min(trueLength, maxLength)
  88.       set the movieRate of sprite 44 to 0
  89.       set the movieTime of sprite 44 to newPosition
  90.       set the loc of sprite 44 to offScreen
  91.       set the movieTime of sprite 45 to 0
  92.       updateStage()
  93.       set the loc of sprite 45 to onScreen
  94.       set the movieRate of sprite 45 to 1
  95.       set the visible of sprite 45 to 1
  96.       set the volume of sprite 45 to abs(the volume of sprite 45)
  97.       updateStage()
  98.       set stopTime to the ticks + rewindLength
  99.       repeat while the ticks < stopTime
  100.         updateStage()
  101.       end repeat
  102.       set the visible of sprite 45 to 0
  103.       set the loc of sprite 45 to offScreen
  104.       set the movieRate of sprite 45 to 0
  105.       set the loc of sprite 44 to onScreen
  106.       set the movieTime of sprite 44 to newPosition
  107.       updateStage()
  108.       set the movieRate of sprite 44 to 1
  109.       updateStage()
  110.     end if
  111.     if whichBtn = #pause then
  112.       set the movieRate of sprite 44 to 0
  113.     end if
  114.     if whichBtn = #play then
  115.       if the movieTime of sprite 44 > 15000 then
  116.         set the movieTime of sprite 44 to 15000
  117.       else
  118.         set the movieTime of sprite 44 to the movieTime of sprite 44
  119.       end if
  120.       set the movieRate of sprite 44 to 1
  121.     end if
  122.   else
  123.   end if
  124. end
  125.  
  126. on setvideoTapePosition suggestion
  127.   global oStoryteller
  128.   setProp(the lsStateData of oStoryteller, #videoTapePosition, [suggestion])
  129. end
  130.  
  131. on freezeInventory
  132.   global oStoryteller, oPuppeteer, gFreezeInventory
  133.   set the inventoryStatus of oPuppeteer to #cool
  134.   setState(oStoryteller, #inventoryStatus, #cool)
  135.   set gFreezeInventory to 1
  136. end
  137.  
  138. on unFreezeInventory
  139.   global gFreezeInventory
  140.   setState(oStoryteller, #inventoryStatus, #hot)
  141.   set gFreezeInventory to 0
  142. end
  143.  
  144. on testForPsionicWaves suggestion
  145.   global oStoryteller, oPuppeteer
  146.   set cameraFeedbackRemaining to count(getProp(the lsStateData of oStoryteller, #cameraFeedbackRemaining))
  147.   set oscillatorInPlace to getState(oStoryteller, #oscillatorInPlace)
  148.   set tonalResidueRemaining to count(getProp(the lsStateData of oStoryteller, #tonalResidueRemaining))
  149.   if (cameraFeedbackRemaining < 1) and oscillatorInPlace and (tonalResidueRemaining < 4) then
  150.     setState(oStoryteller, #psionicWavesPresent, 1)
  151.     if inState(#hauntsRemaining, #phoneMessage) then
  152.       setState(oStoryteller, #ghostlyPhoneCall, #ringingNow)
  153.     end if
  154.   end if
  155. end
  156.  
  157. on setGhostlyPhoneCall suggestion
  158.   global oStoryteller, oPuppeteer
  159.   set currentState to getState(oStoryteller, #ghostlyPhoneCall)
  160.   if not getPos([#notyet, #ringingNow, #speaking, #done], suggestion) then
  161.     alert(" Sorry, " & suggestion & " is not an acceptable value for #ghostlyPhoneCall...")
  162.     exit
  163.   end if
  164.   if suggestion = #ringingNow then
  165.     if voidp(the lsEarshot of oPuppeteer) then
  166.       set phoneVol to 0
  167.     else
  168.       set phoneVol to getaProp(the lsEarshot of oPuppeteer, #phoneVol)
  169.       if not integerp(phoneVol) then
  170.         set phoneVol to 0
  171.       end if
  172.     end if
  173.     setLoop(#phoneRinging, phoneVol)
  174.     updateStage()
  175.   end if
  176.   if suggestion = #speaking then
  177.     cursorOff()
  178.     endLoop(#phoneRinging)
  179.     if (getState(oStoryteller, #psionicWavesPresent) = 1) and inState(#hauntsRemaining, #phoneMessage) then
  180.       soundEffect(#phoneRoxy)
  181.       wait(#soundStop, #phoneRoxy)
  182.       set suggestion to #done
  183.       setLoop(#roxyCallDone)
  184.       trimState(#hauntsRemaining, #phoneMessage)
  185.       trimState(#hauntsRemaining, #spookyOperator)
  186.       setState(oStoryteller, #AMBERVISION, #waitingForPlayer)
  187.       setState(oStoryteller, #PKamberStatus, #WaveActivated)
  188.       setState(oStoryteller, #PeekDisplay, #amberStatus)
  189.     else
  190.       if inState(#hauntsRemaining, #spookyOperator) then
  191.         if getState(oStoryteller, #phoneButtonsPressed) > 6 then
  192.           soundEffect(#spookyOperator)
  193.           wait(#soundStop, #spookyOperator)
  194.           trimState(#hauntsRemaining, #spookyOperator)
  195.           setProp(the lsStateData of oStoryteller, #phoneButtonsPressed, [0])
  196.           setLoop(#phoneDead)
  197.         end if
  198.       else
  199.         if inState(#hauntsRemaining, #phoneMessage) then
  200.           setLoop(#phoneDead)
  201.         else
  202.           setLoop(#roxyCallDone)
  203.         end if
  204.       end if
  205.     end if
  206.   end if
  207.   if suggestion = #done then
  208.     cursorOn()
  209.     endLoop(#phoneRinging)
  210.     endLoop(#spookyOperator)
  211.     endLoop(#phoneRoxy)
  212.     testForPsionicWaves()
  213.   end if
  214.   setProp(the lsStateData of oStoryteller, #ghostlyPhoneCall, [suggestion])
  215. end
  216.  
  217. on ghostCalls suggestion, howLoud
  218.   global oStoryteller
  219.   set possibleCallLists to [#allGhosts, #Brice_entry, #Margaret_entry, #Edwin_entry, #Brice_warm, #Margaret_warm, #Edwin_warm, #Brice_cool, #Margaret_cool, #Edwin_cool, #none]
  220.   set valueCheck to getPos(possibleCallLists, suggestion)
  221.   if valueCheck = 0 then
  222.     exit
  223.   end if
  224.   set suggestedCalls to []
  225.   if suggestion = #allGhosts then
  226.     repeat with theGhost in [#Margaret, #Brice, #Edwin]
  227.       if inState(#ghostsRemaining, theGhost) then
  228.         append(suggestedCalls, theGhost)
  229.         append(suggestedCalls, #nobody)
  230.         append(suggestedCalls, #nobody)
  231.         append(suggestedCalls, #nobody)
  232.       end if
  233.     end repeat
  234.   end if
  235.   if suggestion = #Brice_entry then
  236.     if inState(#ghostsRemaining, #Brice) then
  237.       set suggestedCalls to [#Brice]
  238.     end if
  239.   end if
  240.   if suggestion = #Margaret_entry then
  241.     if inState(#ghostsRemaining, #Margaret) then
  242.       set suggestedCalls to [#Margaret]
  243.     end if
  244.   end if
  245.   if suggestion = #Edwin_entry then
  246.     if inState(#ghostsRemaining, #Edwin) then
  247.       set suggestedCalls to [#Edwin]
  248.     end if
  249.   end if
  250.   if suggestion = #Brice_warm then
  251.     if inState(#ghostsRemaining, #Brice) then
  252.       set suggestedCalls to [#Brice, #nobody, #nobody]
  253.     end if
  254.   end if
  255.   if suggestion = #Margaret_warm then
  256.     if inState(#ghostsRemaining, #Margaret) then
  257.       set suggestedCalls to [#Margaret, #nobody, #nobody]
  258.     end if
  259.   end if
  260.   if suggestion = #Edwin_warm then
  261.     if inState(#ghostsRemaining, #Edwin) then
  262.       set suggestedCalls to [#Edwin, #nobody, #nobody]
  263.     end if
  264.   end if
  265.   if suggestion = #Brice_cool then
  266.     if inState(#ghostsRemaining, #Brice) then
  267.       set suggestedCalls to [#Brice, #nobody, #nobody, #nobody]
  268.     end if
  269.   end if
  270.   if suggestion = #Margaret_cool then
  271.     if inState(#ghostsRemaining, #Margaret) then
  272.       set suggestedCalls to [#Margaret, #nobody, #nobody, #nobody]
  273.     end if
  274.   end if
  275.   if suggestion = #Edwin_cool then
  276.     if inState(#ghostsRemaining, #Edwin) then
  277.       set suggestedCalls to [#Edwin, #nobody, #nobody, #nobody]
  278.     end if
  279.   end if
  280.   if count(suggestedCalls) < 1 then
  281.     set suggestedCalls to [#nobody]
  282.   end if
  283.   report("<i>  suggestedCalls = " & suggestedCalls)
  284.   setProp(the lsStateData of oStoryteller, #ghostsCalling, suggestedCalls)
  285.   if suggestion = #none then
  286.     set the volume of sound 5 to 50
  287.   else
  288.     set volCheck to getaProp([#low: 90, #medium: 180, #high: 255], howLoud)
  289.     if voidp(volCheck) then
  290.     else
  291.       set the volume of sound 5 to volCheck
  292.     end if
  293.   end if
  294.   setProp(the lsStateData of oStoryteller, #ghostCallVol, [the volume of sound 5])
  295.   report("<i>  ghostCalls(): New volume is " & the volume of sound 5)
  296. end
  297.  
  298. on playDomainEntrySound
  299.   global oStoryteller, oPuppeteer, gCurrentEntrySounds, gSoundPath, gEntrySoundFiles, domainIsReady, gSoundsSuspended
  300.   if gSoundsSuspended = 1 then
  301.     exit
  302.   end if
  303.   if domainIsReady = 0 then
  304.     exit
  305.   end if
  306.   if not soundBusy(5) then
  307.     set batterUp to getState(oStoryteller, #ghostsCalling)
  308.     if (batterUp <> #nobody) or (waitAsec() = #finished) then
  309.       set the volume of sound 5 to getState(oStoryteller, #ghostCallVol)
  310.       if voidp(gCurrentEntrySounds) then
  311.         set gCurrentEntrySounds to [#Margaret: 1, #Brice: 1, #Edwin: 1, #nobody: 1]
  312.         set gEntrySoundFiles to [#Margaret: ["Mcall1.aif", "Mcall10.aif", "Mcall2.aif", "Mcall3.aif", "Mcall4.aif", "Mcall5.aif", "Mcall6.aif", "Mcall7.aif", "Mcall8.aif", "Mcall9.aif"], #Brice: ["Bcall1.aif", "Bcall10.aif", "Bcall11.aif", "Bcall2.aif", "Bcall3.aif", "Bcall4.aif", "Bcall5.aif", "Bcall6.aif", "Bcall7.aif", "Bcall8.aif", "Bcall9.aif"], #Edwin: ["Ecall1.aif", "Ecall10.aif", "Ecall11.aif", "Ecall12.aif", "Ecall2.aif", "Ecall3.aif", "Ecall4.aif", "Ecall5.aif", "Ecall6.aif", "Ecall7.aif", "Ecall8.aif", "Ecall9.aif"], #nobody: ["Nobody.aif"]]
  313.       end if
  314.       set soundList to getProp(gEntrySoundFiles, batterUp)
  315.       set oldSound to getProp(gCurrentEntrySounds, batterUp)
  316.       set newSound to (oldSound mod count(soundList)) + 1
  317.       if batterUp = #nobody then
  318.         waitAsec(#start)
  319.       else
  320.         sound playFile 5, gSoundPath & getAt(soundList, newSound)
  321.       end if
  322.       setProp(gCurrentEntrySounds, batterUp, newSound)
  323.       if count(getProp(the lsStateData of oStoryteller, #ghostsCalling)) > 1 then
  324.         set statelist to getProp(the lsStateData of oStoryteller, #ghostsCalling)
  325.         addAt(statelist, 1, getLast(statelist))
  326.         deleteAt(statelist, count(statelist))
  327.       end if
  328.     end if
  329.   end if
  330. end
  331.  
  332. on togglePreloading
  333.   global gPreloading
  334.   set gPreloading to not gPreloading
  335.   unLoadCast()
  336.   if gPreloading then
  337.   else
  338.   end if
  339. end
  340.  
  341. on toggleTransitions qualityDesired
  342.   global gStopTransitions, oPuppeteer, gTransQuality
  343.   set gTransQuality to qualityDesired
  344.   if qualityDesired = #none then
  345.     set gStopTransitions to 1
  346.   else
  347.     set gStopTransitions to 0
  348.   end if
  349.   if qualityDesired = #Better then
  350.     setProp(the lsMachineProfile of oPuppeteer, #transitions, [#turnRight: "02,1,16,TRUE", #turnLeft: "01,1,16,TRUE", #forward: "09,1,8,TRUE", #lookAt: "09,1,8,TRUE", #backOff: "10,1,8,TRUE", #lookUp: "03,1,16,TRUE", #lookDown: "04,1,16,TRUE", #fadeIn: "50,2,0,TRUE", #slowMontage: "50,3,0,TRUE", #nextPage: "2,2,32,TRUE", #prevPage: "1,2,32,TRUE"])
  351.   end if
  352.   if qualityDesired = #Best then
  353.     setProp(the lsMachineProfile of oPuppeteer, #transitions, [#turnRight: "02,1,16,TRUE", #turnLeft: "01,1,16,TRUE", #forward: "26,2,0,TRUE", #lookAt: "26,2,0,TRUE", #backOff: "26,2,0,TRUE", #lookUp: "03,1,16,TRUE", #lookDown: "04,1,16,TRUE", #fadeIn: "26,2,0,TRUE", #slowMontage: "26,3,0,TRUE", #nextPage: "2,2,16,TRUE", #prevPage: "1,2,16,TRUE"])
  354.   end if
  355. end
  356.  
  357. on toggleBitDepth
  358.   global g16bit
  359.   if g16bit then
  360.     set the colorDepth to 8
  361.     if the colorDepth = 8 then
  362.       set g16bit to 0
  363.     else
  364.       alert("Couldn't set the colordepth to 8-bit.. (Check the Monitors control panel for this monitor)")
  365.     end if
  366.   else
  367.     set the colorDepth to 16
  368.     if the colorDepth = 16 then
  369.       set g16bit to 1
  370.     else
  371.       alert("Couldn't set the colordepth to 16-bit.. (Check the Monitors control panel for this monitor)")
  372.     end if
  373.   end if
  374.   if g16bit then
  375.   else
  376.   end if
  377. end
  378.  
  379. on selectiveUpdate castlist
  380.   global oPuppeteer, oStoryteller
  381.   set castUpdates to []
  382.   set spotUpdates to []
  383.   set match to #none
  384.   repeat with teststring in castlist
  385.     repeat with candidate in the lsOnStage of oPuppeteer
  386.       if getProp(candidate, #castName) = teststring then
  387.         set match to candidate
  388.         put RETURN & "match = " & match
  389.         exit repeat
  390.       end if
  391.     end repeat
  392.     if match <> #none then
  393.       append(lsUpdates, match)
  394.       set match to #none
  395.       next repeat
  396.     end if
  397.     repeat with candidate in the lsAllHotspots of oPuppeteer
  398.       if getAt(getAt(candidate, 3), 1) = teststring then
  399.         set match to candidate
  400.         put RETURN & "match = " & match
  401.         exit repeat
  402.       end if
  403.     end repeat
  404.     if match = #none then
  405.       alert("No match for string: '" & teststring & "'")
  406.       next repeat
  407.     end if
  408.     append(lsUpdates, match)
  409.     set match to #none
  410.   end repeat
  411.   put RETURN & ">> FINAL LIST <<"
  412.   put castUpdates
  413. end
  414.  
  415. on changePal startCast, finishCast, newPalette
  416.   set newPaletteNumber to the number of cast newPalette
  417.   repeat with i = startCast to finishCast
  418.     if the castType of cast i = #bitmap then
  419.       set the palette of cast i to newPaletteNumber
  420.       next repeat
  421.     end if
  422.     put the name of cast i & " is not a #bitmap castmember."
  423.   end repeat
  424. end
  425.